import type { FC } from "react";
import { Popconfirm, Button } from "antd";
import { resetAllStore } from "@/store/resetters.ts";
import { useNavigate } from "react-router-dom";

const Logout: FC = () => {
  const navigate = useNavigate();
  const logout = () => {
    // 清空 store 中的数据
    resetAllStore();
    // 跳转到登录页面
    navigate("/login");
  };
  return (
    <Popconfirm
      placement="bottom"
      title="退出登录"
      description="您确认退出登录吗？"
      okText="确认"
      cancelText="取消"
      onConfirm={logout}
    >
      <Button type="link">退出登录</Button>
    </Popconfirm>
  );
};

export default Logout;